home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991 …esperately Seeking Seven / Desperately Seeking Seven.2mg / Dev.CD.8 / Essentials / Tools / DTS.Samples / SC02BusyBox / BusyBox.c / UWindow.c < prev   
Encoding:
C/C++ Source or Header  |  1990-05-25  |  3.0 KB  |  122 lines  |  [04] ASCII Text (0x0000)

  1. /***********************************************************************
  2. *
  3. * busybox uwindow.c -- Version 3.0 
  4. *
  5. * Copyright (c)
  6. * Apple Computer, Inc.  1986-1990
  7. * All Rights Reserved.
  8. *
  9. * Developer Technical Support Apple II Sample Code
  10. *
  11. * This file contains the code which implements  
  12. * windows in the busybox program.
  13. *
  14. ***********************************************************************/
  15.  
  16. #include <types.h>
  17. #include <quickdraw.h>
  18. #include <resources.h>
  19. #include <window.h>
  20.  
  21. #include "busybox.h"
  22.  
  23. extern GrafPortPtr      windowList[SHORTINDEX];
  24. extern unsigned int     staggerCount;
  25.  
  26. #define MainWindowID    0x2000L
  27.  
  28.  
  29.  
  30. /***********************************************************************
  31. *
  32. * drawThisWindow
  33. *
  34. * This routine draws the contents of all the windows.
  35. *
  36. ***********************************************************************/
  37. void    drawThisWindow()
  38. {
  39.     DrawControls(GetPort());
  40. }
  41.  
  42.  
  43.     
  44. /***********************************************************************
  45. *
  46. * doCloseTop
  47. *
  48. * This routine closes the topmost window.  We do a little work to
  49. * prevent the main window from being closed.
  50. *
  51. ***********************************************************************/
  52. void    doCloseTop()
  53. {
  54.     unsigned int    k;
  55.     GrafPortPtr     tempWin;
  56.  
  57.     tempWin = FrontWindow();
  58.         
  59.     /* Find the window entry, close the window, and zero the entry */
  60.     /* start the count at 1 since we never close the main window */
  61.     for (k = 1; k < NumWindows; k++) {
  62.         if (tempWin == windowList[k]) {
  63.             CloseWindow(tempWin);
  64.             windowList[k] = NULL;
  65.             break;
  66.         }
  67.     }
  68. }
  69.  
  70.  
  71.  
  72. /***********************************************************************
  73. *
  74. * openThisWindow
  75. *
  76. * This routine either opens the specified window or brings it to the top
  77. * if it is already open.
  78. *
  79. * If it is not open, we open it with NewWindow2 invisibly, adjust the window's
  80. * location and then show and select the window.
  81. *
  82. ***********************************************************************/
  83. void            openThisWindow(ctlid)
  84. unsigned int    ctlid;
  85. {
  86.     GrafPortPtr     wptr;
  87.  
  88.     if (!(wptr = windowList[ctlid])) {
  89.         windowList[ctlid] = wptr = NewWindow2(NULL, NULL, drawThisWindow, NULL, 2,
  90.             ctlid + MainWindowID, rWindParam1);
  91.         if (ctlid < Prog1ID) {
  92.             MoveWindow (50 + 8 * staggerCount, 50 + 8 * staggerCount, wptr);
  93.             staggerCount++;
  94.             staggerCount &= 0x0F;
  95.         }
  96.         ShowWindow(wptr);
  97.         SelectWindow(wptr);             
  98.     }
  99.     else SelectWindow(wptr);
  100. }
  101.     
  102.  
  103.     
  104. /***********************************************************************
  105. *
  106. * setupWindows
  107. *
  108. * Sets up windowList record for use through out the program.
  109. *
  110. ***********************************************************************/
  111. void    setupWindows()
  112. {
  113.     unsigned int    k;
  114.  
  115.     /* Zero out the entries in the window list. */
  116.     for (k = 0; k < NumWindows; k++) windowList[k] = NULL;
  117.  
  118.     /* Open the main window */
  119.     windowList[0] = NewWindow2(NULL, NULL, drawThisWindow, NULL, 2,
  120.         MainWindowID, rWindParam1);
  121. }
  122.